<?php
include_once(dirname(__FILE__) . '/../domain/Clinician.php');
include_once(dirname(__FILE__) . '/../database/dbClinician.php');
include_once('checkRoutines.inc');

define("NPI","4555454545");
define("ID","Gabrielle".NPI);
define("FIRST NAME", "Gabrielle");
define("LAST NAME", "DeSanchez");
define("SPECIALITY", "Dental");
define("PHONE", "2333334545");
define("CELL", "3444445656");
define("SSN","444-44-4444");
define("AVAILABILITY", "Mon-Fri 9-5");



echo 'testing dbClinician.php</br>';
testAddClinician();
testRetrieveClinician();
testRetrieve_clinician_by_name();
testRetrieve_clinician_by_speciality();
testRetrieve_clinician_by_ssn();
testRetrieve_clinician_by_npi();

echo("testdbClinicians complete</br>");

// tests the add_clinician() function in dbClinicians.php
function testAddClinician() {
    $clinician = new Clinician("Gabrielle", "DeSanchez", "Dental", "2333334545", "3444445656","444-44-4444","","4555454545");
    echo 'clinician object id is'. $clinician->get_id().'</br>';
    echo 'will test add_clinician </br>';
    $result = add_clinician($clinician);
    echo 'result is ' . $result.'</br>';
    if ($result)
        echo "clinician was inserted</br>";
    else
        echo "clinician was not inserted</br>";

    $res = remove_clinician(ID);
    if ($res == null)
        echo 'Remove failed</br>';
}

// tests the retrieve_clinician() function in dbClinicians.php
function testRetrieveClinician() {
     $clinician = new Clinician("Gabrielle", "DeSanchez", "Dental", "2333334545", "3444445656","444-44-4444","","4555454545");
 
    echo 'will test retrieve_clinician </br>';
    $result = add_clinician($clinician);
    echo 'result is ' . $result.'</br>';
    if ($result)
        echo "clinician was inserted </br>";
    else
        echo "clinician not inserted</br>";

    $clinician = retrieve_clinician(ID);
    if ($clinician == null)
        echo 'Retrieve failed</br>';
    else {
        checkEquals($clinician->get_fname(), "Gabrielle");
        checkEquals($clinician->get_SSN(),"444-44-4444");
    }

    $res = remove_clinician(ID);
    if ($res == null)
        echo 'Remove failed</br>';
}

// tests the retrieve_clinicians_by_name() function in dbPersons.php
function testRetrieve_clinician_by_name() {
 
 $clinician = new Clinician("Gabrielle", "DeSanchez", "Dental", "2333334545", "3444445656","444-44-4444","","4555454545");
    echo 'will test retrieve_clinician_by_name </br>';
    $result = add_clinician($clinician);
    echo 'result is ' . $result.'</br>';
    if ($result)
        echo "clinician was inserted</br>";
    else
        echo "clinician was not inserted</br>";

    echo "test retrieve_clinician_by_name</br>";
    $personList = retrieve_clinician_by_name("Gabrielle DeSanchez");
    if ($personList == null)
        echo 'Retrieve by name failed</br>';
    else {
        checkEquals($personList[0]->get_fname(), "Gabrielle");
        checkEquals($personList[0]->get_SSN(), "444-44-4444");
    }

    $res = remove_clinician(ID);
    if ($res == null)
        echo 'Retrieve failed</br>';
}

// tests the retrieve_clinicians_by_speciality() function in dbPersons.php
function testRetrieve_clinician_by_speciality() {
 
 $clinician = new Clinician("Gabrielle", "DeSanchez", "Dental", "2333334545", "3444445656","444-44-4444","","4555454545");
    echo 'will test retrieve_clinician_by_speciality </br>';
    $result = add_clinician($clinician);
    if ($result)
        echo "clinician was inserted</br>";
    else
        echo "clinician was not inserted</br>";

    echo "test retrieve_clinician_by_speciality</br>";
    $personList = retrieve_clinician_by_speciality("Dental");
    if ($personList == null)
        echo 'Retrieve by speciality failed</br>';
    else {
        checkEquals($personList[0]->get_fname(), "Gabrielle");
        checkEquals($personList[0]->get_SSN(), "444-44-4444");
    }

    $res = remove_clinician(ID);
    if ($res == null)
        echo 'Retrieve failed</br>';
}
function testRetrieve_clinician_by_ssn() {
 
 $clinician = new Clinician("Gabrielle", "DeSanchez", "Dental", "2333334545", "3444445656","444-44-4444","","4555454545");
    echo 'will test retrieve_clinician_by_ssn </br>';
    $result = add_clinician($clinician);
    if ($result)
        echo "clinician was inserted</br>";
    else
        echo "clinician was not inserted</br>";

    echo "test retrieve_clinician_by_ssn</br>";
    $personList = retrieve_clinician_by_ssn("444-44-4444");
    if ($personList == null)
        echo 'Retrieve by speciality failed</br>';
    else {
        checkEquals($personList[0]->get_fname(), "Gabrielle");
        checkEquals($personList[0]->get_SSN(), "444-44-4444");
    }
    
 function testRetrieve_clinician_by_npi() {
 
    $clinician = new Clinician("Gabrielle", "DeSanchez", "Dental", "2333334545", "3444445656","444-44-4444","","4555454545");
    echo 'will test retrieve_clinician_by_npi </br>';
    $result = add_clinician($clinician);
    if ($result)
        echo "clinician was inserted</br>";
    else
        echo "clinician was not inserted</br>";

    echo "test retrieve_clinician_by_npi</br>";
    $personList = retrieve_clinician_by_npi("4555454545");
    if ($personList == null)
        echo 'Retrieve by speciality failed</br>';
    else {
        checkEquals($personList[0]->get_npi(), "4555454545");
    }

    $res = remove_clinician(ID);
    if ($res == null)
        echo 'Retrieve failed</br>';
}

}